<template>
	
	<!-- <view class="wrap"> -->
		<view class="wrap">
		<myScan ref="myScan" v-if="scanCodeIsShow" @scanCode="scanCode"></myScan>
		<ErrDialog v-if="errDialogOpen" ref="errDialog" :dialogData="dialogData" @retryFunciton="retryFunciton">
		</ErrDialog>
		<u-tabs :list="list" :current="current" @change="change"></u-tabs>
		<view style="padding-bottom: 140rpx;">
			
			<!-- 当前套餐 -->
			<view v-if="current === 0" >
				<view class="my-body">
					<u-form-item label="工作站" label-width="170">
						<uni-data-select class="my-select" placeholder="请选择工作站" v-model="GZTID"
							@showSelector="showSelector($event)" :localdata="gztList"
							@change="changeGzt"></uni-data-select>
					</u-form-item>
					<view v-show="showHeight" style="margin: 460rpx;"></view>
				</view>
				<u-empty v-if="!hzList.length" text="无明细数据,请尝试不同的搜索条件进行搜索" mode="page"></u-empty>
				<u-card v-for="(item, index) in hzList" class="task-list-item" :border="false" padding="20"
					margin="20rpx" @click="goTo(item,index)">
					<view slot="head" style="display: flex;align-items: center;justify-content: space-between;">
						<view style="display: flex;align-items: center;font-size: 30rpx;">
							{{index+1}}.货位：{{item.LOCATION}}
						</view>
						<view style="color: #999999;font-size: 22rpx;">{{item.KUF_NO}}</view>
					</view>
					<view class="" slot="body">
						<u-row gutter="16">
							<u-col span="12">
								<view class="apply-text"><span>区域：</span>{{item.QUY_NO}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>货位：</span>{{item.LOCATION}}</view>
							</u-col>
							<u-col span="12">
								<view class="apply-text"><span>托盘：</span>{{item.TPBAR}}</view>
							</u-col>
						</u-row>
					</view>
				</u-card>
				<u-loadmore :status="status" />
				<u-row gutter="32" class="more-bottom-box" justify="center">
					<u-col span="10">
						<view>
							<u-button class="more-button" type="primary" shape="circle" @click="searchHz">搜索</u-button>
						</view>
					</u-col>
				</u-row>
			</view>
			<!-- class="example-body" -->
			<view v-if="current === 1" >
				<!-- 给第一个为默认值 -->
				<u-empty v-if="!huojGoodsList.length" text="请选择一条汇总信息" mode="page"></u-empty>
				{{ devShow ? selectedMx : ''}}
				<u-checkbox-group  v-model="SEQNO" @change="radioGroupChange">
					<!-- padding="20"
						margin="20rpx" -->
						 <!-- class="task-list-item" -->
					<u-card v-for="(item, index) in huojGoodsList" :border="false" 
				  padding="20"
					margin="20rpx"
						>
						<view slot="head" style="display: flex;align-items: center;justify-content: space-between;">
							<view style="display: flex;align-items: center;font-size: 30rpx;">
								{{index+1}}.{{item.GDNAME}}
							</view>
							<view style="color: #999999;font-size: 22rpx;">{{item.BATCHNO}}</view>
						</view>
						<view class="" slot="body">
							<u-row gutter="16">
								<u-col span="12">
									<view class="apply-text"><span>显示货位：</span>{{item.LOCATION}}</view>
								</u-col>

								<u-col span="12">
									<view class="apply-text"><span>业主名称：</span>{{item.YEZ_NAME}}</view>
								</u-col>
								<u-col span="12">
									<view class="apply-text"><span>上游编码：</span>{{item.GDSEQ}}</view>
								</u-col>
								<u-col span="12">
									<view class="apply-text"><span>商品名称：</span>{{item.GDNAME}}</view>
								</u-col>
								<u-col span="12">
									<view class="apply-text"><span>商品规格：</span>{{item.GDSPEC}}</view>
								</u-col>
								<u-col span="12">
									<view class="apply-text"><span>生产厂家：</span>{{item.PRODUCERNAME}}</view>
								</u-col>
								<!-- <u-col span="12">
							<view class="apply-text"><span>批次ID：</span>{{item.ITEMID}}</view>
						</u-col> -->
								<u-col span="12">
									<view class="apply-text"><span>批号：</span>{{item.BATCHNO}}</view>
								</u-col>
								<u-col span="12">
									<view class="apply-text"><span>效期：</span>{{item.EFFDATE}}</view>
								</u-col>
								<u-col span="12">
									<view class="apply-text"><span>生产日期：</span>{{item.PRODUCTDATE}}</view>
								</u-col>
								<u-col span="12">
									<view class="apply-text"><span>包装数量：</span>{{item.NUM_DABZ}}</view>
								</u-col>
								<u-col span="12">
									<view class="apply-text"><span>系统数量：</span>{{item.AMOUNT}}</view>
								</u-col>
								<u-col span="12">
									<view class="apply-text"><span>托盘号：</span>{{item.TPBAR}}</view>
								</u-col>
								<!-- <u-col span="12">
									<u-form-item label="额外唯一码" label-width="180">
										<uni-easyinput v-model="item.moreUniqcode"></uni-easyinput>
									</u-form-item>
								</u-col> -->
								<u-divider color="#fa3534" half-width="400"></u-divider>
								<u-checkbox @change="radioChange" v-model="item.checked" :key="index"
									:name="item.PDNO+'@'+item.SORTSN">
									选择此条数据</u-checkbox>
							</u-row>
						</view>
					</u-card>
				</u-checkbox-group>
			</view>
			<u-row v-if="current === 1" gutter="32" class="more-bottom-box" justify="center">
				<u-col span="10" @click="changeScanInput('form.boxNumber')">
					<view>
						<u-form-item :label="uniqcodeLable" label-width="120">
							<u-input style="margin-bottom: 0rpx;margin-top:12rpx;" border ref="form.uniqcode"
								:focus="uniqcodeFocus" @confirm="submitCheckAll" v-model="form.uniqcode"
								@click="changeScanInput('form.uniqcode')" placeholder="请扫码或输入唯一码">
							</u-input>
						</u-form-item>
					</view>
				</u-col>
				<u-col span="10">
					<view class="my-button-group">
						<u-button :disabled="!selectedMx" class="more-button2"  shape="circle"
								@click="submitPdaBack()">货架返回</u-button>
					</view>					
				</u-col>
				<u-col span="10">
					<view class="my-button-group">
						<u-button :disabled="!selectedMx" class="tow-button"  shape="circle"
								@click="submitCheckAll('',true)">额外提交</u-button>
						<u-button :disabled="!selectedMx" class="tow-button" type="primary" shape="circle"
							@click="submitCheckAll()">提交</u-button>
					</view>					
				</u-col>
				
			</u-row>
		</view>

	</view>
</template>
<script>
	import ErrDialog from '@/components/err-dialog.vue'
	import myScan from '@/components/pda/pda-sacn/my-scan'
	export default {
		components: {
			ErrDialog,
			myScan
		},

		data() {
			return {
				scanCodeIsShow: true, //控制监听扫描头 组件重新加载
				// 需要判断是哪个输入框
				scanInput: "",


				showHeight: false,
				notChangeQuyNo: true,
				uniqcodeFocus: false,
				form: {
					kuf_no: '',
					quy_no: '',
					gztid: '',
					tpNum: '1',
					//1：空托入库2：空托出库
					czlx: '1',
					landpoint: 'DHJ01',
					tpbar: '',
					uniqcode: '',
					moreUniqcode: '',
				},
				uniqcodeLable:'唯一码',
				errDialogOpen: false,
				// 提示信息
				dialogData: {
					title: '出库',
					msgType: '',
					errContent: '',
					confirmText: '',
					functionName: '',
					cancelText: '',
					closeFunction: '',
				},
				//是否为正常物料
				ISZCGD: '',
				keywords: '',
				form: {
					huoz_id: '',
					tpbar: '',
					itm: '',
					rwid: '',
				},
				border: true,
				show: false,
				//库房展示
				kufShow: false,

				// 工作台下拉展示
				gzzShow: false,
				// 当前工作台中文
				gztNowLabel: '',
				GZTID: '',
				tips: '工作站选择',

				// 被选中的商品明细下标
				selectItemIndex: '',
				selectedMx: [],
				// 托盘的商品明细
				// huojGoodsList: [],
				// 货架上的货位商品明细
				huojGoodsList: [],
				
				mxInfo:{},

				demo_amount: '',

				//选中的明细
				SEQNO: '',
				// 选中的货架号
				HUOJNO: '',
				//选中的货架面
				ORIENTATIONS: '',
				//当前选中的托盘号
				tpbar: '',
				kuf: '',
				// 商品相关条件
				goods: '',
				//库房
				kufList: [],
				//区域
				quNoList: [],
				//库别
				kubList: [],
				//工作台
				gztList: [],
				//日历选择显示
				calendaShow: false,
				//有效期日历显示
				calendaEffdateShow: false,
				list: [{
					name: '明细筛选'
				}, {
					name: '明细总览',
				}],

				m2mSimflowList: [],
				m2mOrderFlowList: [],
				current: 0,
				result1: '',
				status: 'nomore',
				iconType: 'circle',
				isDot: false,
				loadText: {
					loadmore: '点击加载更多',
					loading: '正在加载...',
					nomore: '没有更多了'
				},
				// 搜索栏的托盘号
				tpbar: '',
				nvueWidth: 730,
				only_one: [{
					text: '选择此项',
					value: 0
				}],
				// 基础表单数据
				baseFormData: {
					name: '',
					age: '',
					introduction: '',
					sex: 2,
					hobby: [5],
					datetimesingle: 1627529992399
				},
				// 开发环境的判定
				devShow: false,
				// 汇总信息存储
				hzData: {

				},
				// 点击的汇总下标
				hzIndex: '',
				refreshInHead: true,
				refreshMxMsg: true,
				hzList: [],

				oneMx: {},
				disableTrue: true,
				// 入库点
				landpoint: '',
				sjAmouont: '1',
				sjLocation: '',
			}
		},
		// 该写提交盘点单了 接口7

		onLoad(option) {
			// this.form.kuf_no = uni.getStorageSync("inventory-check-kuf_no")
			// this.getKufbyKuf()
			// setTimeout(() => {
			// 	this.form.quy_no = uni.getStorageSync("inventory-check-quy_no")

			// }, 1000)
			// this.form.tpNum=uni.getStorageSync("inventory-check-landpoint")

			// if (option) {
			// 	if (option.item) {
			// 		let item = JSON.parse(option.item)
			// 		this.hzData = item
			// 		console.log('收到的:' + JSON.stringify(item))
			// 		console.log('收到的:' + item.INPAGENO)
			// 		this.tpbar = item.INPAGENO;
			// 		this.getInListOneInfo()
			// 	}
			// }
		},

		created() {
			// this.getKuf(2)
			// this.getKuf(3)
			this.getGzt()
			this.init()
			this.selectedMx = []
			this.searchHz()
			if (process.env.NODE_ENV === 'development') {
				this.devShow = true
				console.log('开发环境');
			} else {
				console.log('生产环境');
			}

		},
		// 数据变化适用
		onShow() {
			this.myShow()

		},
		onBackPress() {
			console.log("点击了返回")
			uni.switchTab({
				url: "/pages/sys/workbench/wms-work"
			})
			return true
		},
		methods: {

			scanCode(res) {
				console.log("父scanCode 收到的数据:" + res)
				this.resultCode(res)
			},
			resultCode(res) {
				this.scanResult = JSON.stringify(res)
				this.changeScanValue()
			},

			// 判定点击的哪个输入框
			changeScanInput(inputItem) {
				this.refreshScan()
				console.log(inputItem)
				this.scanInput = inputItem
			},
			// 刷新扫描组件
			refreshScan() {
				this.scanCodeIsShow = false;
				this.$nextTick(() => {
					this.scanCodeIsShow = true;
				})
			},


			// 扫描后执行的方法,判断输入框并绑定值,可以自行跳转,或者扫描完执行某方法,
			changeScanValue() {
				let scanInput = this.scanInput
				let result = JSON.parse(this.scanResult)
				if ("form.uniqcode" === scanInput) {
					console.log("this.form.uniqcode ")
					this.form.uniqcode = result
					this.submitCheckAll()
				} else if ("sjAmouont" === scanInput) {
					console.log("this.sjAmouont")
					this.sjAmouont = result
				} else {
					//inbillForm.location
					//inbillForm.boxNumber
					//form.boxNumber
					// this.$u.toast('没有预先适配:' + scanInput)
					console.log('changeScanValue()没有预先适配:' + scanInput)
				}

			},



			// 选中某个单选框时，由radio时触发
			radioChange(e) {
				console.log(e);
				this.selectItemIndex = e
			},
			// 选中任一radio时，由radio-group触发
			radioGroupChange(evt) {
				this.selectedMx = evt
				console.log(evt);
			},
			navTo(url) {
				// uni.navigateTo({
				// 	url: url
				// });
				// uni.switchTab({
				// 	url: url
				// });
				uni.switchTab({
					url: url,
					success: function(e) {
						var page = getCurrentPages().pop(); // 返回页面数组的最后一个页面数据
						if (page == undefined || page == null)
							return; //如果最后一个页面为undefined或null，即当前就在首页 return出去，不调用onLoad
						page.onLoad();
					}
				});


			},
			searchHz() {
				// this.getInListOneInfo()
				// this.getOutTpbarList()
				// this.getCheckList()
				this.getCheckList()
			},
			overStyle(over) {
				if (over) {
					return "text-align: right;color: #58ca93;";
				} else {
					return "text-align: right;color: #f28c03;";
				}
			},
			init() {
				this.GZTID = uni.getStorageSync('IN_GZTID')
				// this.kuf = uni.getStorageSync('kuf')
			},
			goTo(item, index) {
				this.huojGoodsList = []
				this.hzData = item
				this.hzIndex = index
				this.getLocationMxList(item)
				console.log('item:' + JSON.stringify(item))
				item.index = Number(index + 1)
				this.change(1)
			},
			getKuf(type) {
				const USER_ID = uni.getStorageSync('USER_ID')
				const KUB = '%'
				const KUF_NO = "%"
				// if(type == "3"){
				// 	KUF_NO = this.form.kuf_no ? this.form.kuf_no : '%'
				// }
				//1获取库别，2获取库房，3获取区域
				const GET_TYPE = type
				let param = USER_ID + "," + KUB + "," + KUF_NO + "," + GET_TYPE;
				this.$u.api.general({
						iv_code: "GETKUFQUYNO",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))

						if (res.success) {
							let data = res.data
							console.log("kuf返回的data:" + JSON.stringify(data))
							console.log("type:" + type)
							//补充text
							// this.kufList = data
							console.log("type:" + type)
							if (type == "2") {
								this.kufList = data.map(v => {
									this.$set(v, 'text', v.KUF_NO)
									this.$set(v, 'value', v.KUF_NO)
									return v
								})
								// console.log("this.kufList:"+JSON.stringify(this.kufList))
							} else if (type == "3") {
								this.quNoList = data.map(v => {
									this.$set(v, 'text', v.QUY_NO)
									this.$set(v, 'value', v.QUY_NO)
									return v
								})
							} else {
								this.kubList = data.map(v => {
									this.$set(v, 'text', v.KUB)
									this.$set(v, 'value', v.KUB)
									return v
								})
							}

						} else {
							this.errContent = res.msg
							this.$u.toast(res.msg);
						}
					});
			},

			retryFunciton(e) {
				console.log("子组件返回的e:" + e)
				if (e == "isNarmalGoods") {
					this.isNarmalGoods()
				} else if (e == "submitCheck") {
					this.submitCheck()
				} else if (e == 'getCheckList') {
					this.getCheckList()
				}else if (e == 'submitPdaBack') {
					this.submitPdaBack()
				}
				
			},
			// 是否是
			isNarmalGoods() {
				if (this.ISZCGD == 'Y') {
					// (对应PDA弹窗提醒)
					this.dialogData = {
						title: '出库检测(正常物料?)',
						msgType: 'warn',
						errContent: '本明细是正常物料',
						confirmText: '我知道了',
						// 如果选右边的执行的返回方法
						functionName: 'submitOut',
						cancelText: '关闭',
					}
					this.errDialogShow()
				} else if (this.ISZCGD == 'N') {
					// 对应pda弹窗选择确认
					this.dialogData = {
						title: '出库检测(正常物料?)',
						msgType: 'error',
						errContent: '本明细不是正常物料',
						confirmText: '同意此物料不是正常物料',
						// 如果选右边的执行的返回方法
						functionName: 'submitOut',
						cancelText: '拒绝',
						closeFunction: 'noNormalGoods',

					}
					this.errDialogShow()
				} else {

				}
			},
			noNormalGoods() {
				this.$u.toast('点击了否,不同意')
			},
			// // 是正常物料的弹窗提示(权限控制,指定账号弹窗)
			// isToast(){

			// },
			errDialogShow() {
				console.log("刷新显示提示框")
				//刷新显示
				let that = this;
				that.errDialogOpen = false;
				that.$nextTick(() => {
					that.errDialogOpen = true;
				})

			},
			// getInListBytpbar() {
			// 	const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
			// 	const huoz_id = "%"
			// 	const USER_ID = uni.getStorageSync('USER_ID')
			// 	const inbillNumber = this.tpbar ? this.tpbar : "%"

			// 	const unit = "%"
			// 	const goodsId = "%"
			// 	const palletNumber = "%"
			// 	let param = STORAGE_ID + "," + huoz_id + "," + USER_ID + "," +
			// 		inbillNumber + "," + unit + "," + goodsId + "," + palletNumber;
			// 	console.log("iv_parm:" + param)
			// 	this.$u.api.general({
			// 			iv_code: "PDAINBILLINPAGENO",
			// 			iv_parm: param
			// 		})
			// 		.then(res => {
			// 			// console.log("返回的res:" + JSON.stringify(res))
			// 			let data = res.data
			// 			console.log("返回的data:" + JSON.stringify(data))
			// 			if (res.success) {
			// 				this.hzData = data[0]
			// 				// if (this.list.length < 1) {
			// 				// 	this.$u.toast("没有查到数据");
			// 				// }
			// 			} else {
			// 				this.$u.toast(res.msg);
			// 			}
			// 		});
			// },
			//重新加载子组件
			myShow() {

				console.log("this.hzData==>" + JSON.stringify(this.hzData))
				//刷新显示
				let that = this;
				that.refreshInHead = false;
				that.$nextTick(() => {
					that.refreshInHead = true;
				})

			},
			myMxShow() {
				//刷新显示
				let that = this;
				that.refreshMxMsg = false;
				that.$nextTick(() => {
					that.refreshMxMsg = true;
				})

			},

			scan1(param) {
				console.log("扫描")
				// #ifdef H5
				this.$u.toast('H5页面不支持扫码,请用安卓等移动设备重试')
				// #endif
				let that = this;
				// 允许从相机和相册扫码
				uni.scanCode({
					success: function(res) {
						if (param == "tpbar") {
							that.tpbar = res.result;
						} else if (param == "LOCATIONZD") {
							that.sjLocation = res.result
						}

					}
				});
			},
			change(index) {
				console.log(this.current)
				this.current = index;
			},
			submit(index) {
				if (this.tpbar) {
					this.$u.toast('调用下架接口')
				} else {
					this.$u.toast('请补充入库单号的数据')
				}
			},
			// 提交选中的明细数据
			submitCheckAll(paramReturn,moreUniqcode) {
				const selected = this.selectedMx
				if (!selected) {
					this.$u.toast('请至少勾选一条要提交的数据')
					return
				}
				if (!this.form.uniqcode) {
					this.$u.toast('请扫描唯一码后再试')
					return
				}
				let success = 0;
				for (let i = 0; i < selected.length; i++) {
					const pdnoAndSortsn = selected[i].split('@')
					// 筛选出来选中的所有选中数据
					const newGoodsList = this.huojGoodsList.filter((item) => {
						return item.PDNO + '@' + item.SORTSN == pdnoAndSortsn[0] + '@' + pdnoAndSortsn[1]
					})
					if (newGoodsList) {
						for (let x = 0; x < newGoodsList.length; x++) {
							success += 1;
							const paramObject = newGoodsList[x];
							this.mxInfo = paramObject
							if(moreUniqcode){
								// 
								this.submitCheckMoreunicode()
							}else{
								//提交选中的
								this.submitCheck('', paramObject)
							}
							
						}
					} else {
						this.change(0)
						this.searchHz()
						this.$u.toast('请选中一条明细,再尝试重新提交')
					}
				}
				if (success >= 1) {
					// this.goTo(this.hzData, this.hzIndex) 
				}
				if (paramReturn == "returnSearch") {
					this.current = 0
				}
			},
			/**
			 * @param {Object} paramReturn 是否返回 tabs1 的页面 [明细筛选]
			 * @param {Object} paramObject 选中的数据对象
			 */
			submitCheck(paramReturn, paramObject) {

				// 1、IV\_STAFF 人员
				// 2、IV\_PDNO 盘点单号
				// 3、IN\_SORTSN 行号
				// 4、IV\_JS 件数
				// 5、IV\_LSS 零散数
				// 6、IN\_AMOUNT 实盘数量

				console.log("oneMx=>" + JSON.stringify(paramObject))
				const USER_ID = uni.getStorageSync('USER_ID')
				const PDNO = paramObject.PDNO ? paramObject.PDNO : "%"
				const SORTSN = paramObject.SORTSN ? paramObject.SORTSN : "1"
				const JS = 1
				const LSS = "0"
				// const AMOUNT = paramObject.SHIP_AMOUNT ? paramObject.SHIP_AMOUNT : "1"
				// 胖子鱼特有,每次盘点一个 http://2444411sa6.qicp.vip/
				const AMOUNT = "1"
				const uniqcode = this.form.uniqcode ? this.form.uniqcode : ""
				let param = USER_ID + "," +
					PDNO + "," +
					SORTSN + "," +
					JS + "," +
					LSS + "," +
					AMOUNT + "," +
					uniqcode;

				console.log("iv_parm:" + param + ";")
				let that = this
				this.$u.api.prcutlexecvar({
						iv_code: "PDRWQR",
						iv_parm: param,
						ov_var1: '2',
						ov_var2: '2',
						ov_var3: '2',
						ov_var4: '2',
						ov_var5: '2',
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						// that.$u.toast(res.msg);
						if (res.success) {

							let data = res.data
							// console.log("返回的data:" + JSON.stringify(data))
							console.log("返回的res.msg:" + res.msg)
							this.submitSuccess()
							that.$u.toast(res.msg);
							if (paramReturn == "returnSearch") {
								this.current = 0
							}
						} else {
							this.dialogData = {
								title: '盘点提交',
								msgType: 'error',
								errContent: res.msg,
								confirmText: '重新提交',
								// 如果选右边的执行的返回方法
								functionName: 'submitCheck',
								cancelText: '关闭',
								closeFunction: '',
							}
							this.errDialogShow()
						}

					});
			},
			
			
			
			// 额外唯一码
			submitCheckMoreunicode(paramReturn, paramObject) {
			
				// 1、IV_STAFF       职员
				// 2、IV_TYPE_BILL     单据类型
				// 3、IV_STORAGEID     仓库
				// 4、IV_GOODSID      商品id
				// 5、IV_ITEMID      批次
				// 6、IV_BATCHNO       批号
				// 7、IV_EFFDATE      生产日期
				// 8、IV_PRODUCTDATE   有效日期
				// 7、IV_LOCATIONID    货位
				// 8、IV_GDSTATUS      质量状态
				// 9、IV_YEW_STATE   业务状态
				// 10、IV_KEEPACCOUNT   保管着
				// 11、IV_CONTAINSNUMBER 内敛数
				// 12、IV_UNIQUECODE     唯一码
				// 13、IV_TPBAR       托盘
				// 14、 IN_AMOUNT       库存数量
				// 15、IN_AMOUNT_NEW     新数量
				// 16、IV_CLTYPE    处理表示  ‘Y’
				
				//  paramObject = {"LOCATION":"A01-011166",
				// "LOCATIONID":"HJK00001066",
				// "NUM_DABZ":"200",
				// "PAND_STAFF":"ADMIN",
				// "EFFDATE":"2028-03-01",
				// "GDSEQ":"997863",
				// "PRODUCTDATE":"2024-03-06","PDLB":"1","ZHIX_STATE":"Z5",
				// "PDNO":"PDD20240327094508828","KEEPACCOUNT":"*",
				// "CONTAINSNUMBER":"*","AMOUNT":"9","YEZ_NAME":"重庆胖子鱼",
				// "SHIP_AMOUNT":"1","SORTSN":"1","UNIT_DABZ":"盒",
				// "BATCHNO":"20240306","ZHIX_FLG":"Y",
				// "GDNAME":"人用狂犬病疫苗（Vero细胞） 0.5ml/剂",
				// "EFFDATE_PRINT":"*","YEW_STATE":"*",
				// "TPBAR":"TP20231225000000000020","GDSTATUS":"1",
				// "STORAGEID":"1010","YEZ_ID":"8888","ITEMID":"5",
				// "UNIQUECODE":"*","checked":true,"disabled":false,
				// "value":"PDD20240327094508828@1","name":"PDD20240327094508828@1"} 
				paramObject = this.mxInfo
				console.log("mxInfo=>" + JSON.stringify(paramObject))
				// return;
				const IV_STAFF = uni.getStorageSync('USER_ID')
				const IV_TYPE_BILL = "1";
				const IV_STORAGEID = uni.getStorageSync('STORAGE_ID')
				const IV_GOODSID = paramObject.GDSEQ;
				const IV_ITEMID = paramObject.ITEMID;
				
				const IV_BATCHNO = paramObject.BATCHNO;
				const IV_EFFDATE = paramObject.EFFDATE;
				const IV_PRODUCTDATE = paramObject.PRODUCTDATE;
				const IV_LOCATIONID = paramObject.LOCATIONID;
				const IV_GDSTATUS = paramObject.GDSTATUS;
				
				const IV_YEW_STATE = paramObject.YEW_STATE; 
				const IV_KEEPACCOUNT = paramObject.KEEPACCOUNT;
				const IV_CONTAINSNUMBER = paramObject.CONTAINSNUMBER;
				const IV_UNIQUECODE = this.form.uniqcode ;
				if(!IV_UNIQUECODE){
					this.$u.toast("唯一码不可以为空");
					return 
				}
				const IV_TPBAR = paramObject.TPBAR;
				
				const IN_AMOUNT = "1";
				const IN_AMOUNT_NEW = "1";
				const IV_CLTYPE = "Y";
				
				
				// const PDNO = paramObject.PDNO ? paramObject.PDNO : "%"
				// const SORTSN = paramObject.SORTSN ? paramObject.SORTSN : "1"
				// const JS = 1
				// const LSS = "0"
				// const AMOUNT = paramObject.SHIP_AMOUNT ? paramObject.SHIP_AMOUNT : "1"
				// 胖子鱼特有,每次盘点一个 http://2444411sa6.qicp.vip/
				const AMOUNT = "1"
				
				let param =IV_STAFF + "," +
				 IV_TYPE_BILL + "," +
				 IV_STORAGEID + "," +
				 IV_GOODSID + "," +
				 IV_ITEMID + "," +
				
				 IV_BATCHNO + "," +
				 IV_EFFDATE + "," +
				 IV_PRODUCTDATE + "," +
				 IV_LOCATIONID + "," +
				 IV_GDSTATUS + "," +

				 IV_YEW_STATE + "," +
				 IV_KEEPACCOUNT + "," +
				 IV_CONTAINSNUMBER + "," +
				 IV_UNIQUECODE + "," +
				 IV_TPBAR + "," +
				
				 IN_AMOUNT + "," +
				 IN_AMOUNT_NEW + "," +
				 IV_CLTYPE 
;
			
				console.log("iv_parm:" + param + ";")
				let that = this
				this.$u.api.prcutlexecvar({
						iv_code: "PDAPDNEWBILL",
						iv_parm: param,
						ov_var1: '2',
						ov_var2: '2',
						ov_var3: '2',
						ov_var4: '2',
						ov_var5: '2',
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						// that.$u.toast(res.msg);
						if (res.success) {
							that.$u.toast(res.msg);
							let data = res.data
							console.log("返回的res.msg:" + res.msg)
							this.submitSuccess()
							if (paramReturn == "returnSearch") {
								this.current = 0
							}
						} else {
							this.dialogData = {
								title: '盘点提交',
								msgType: 'error',
								errContent: res.msg,
								confirmText: '重新提交',
								functionName: 'submitCheckMoreunicode',
								cancelText: '关闭',
								closeFunction: '',
							}
							this.errDialogShow()
						}
					});
			},
			
			
			submitPdaBack() {
				// 1、IV_GZTID  工作台
				// 2、IV_BUCKETNO 货架
				// 3、IV_WORKFACE 货架面
				// 4、IV_STAFF 作业人员
			
				console.log("oneMx=>" + JSON.stringify(this.oneMx))
				const paramObject =this.oneMx
				const IV_GZTID = paramObject.GZTID 
				const IV_BUCKETNO = paramObject.HUOJNO
				const IV_WORKFACE = paramObject.ORIENTATIONS
				const IV_STAFF = uni.getStorageSync('USER_NAME')
				
			
				let param = IV_GZTID + "," +
					IV_BUCKETNO + "," +
					IV_WORKFACE + "," +
					IV_STAFF
			
				console.log("提交货架返回的iv_parm:" + param + ";")
				let that = this
				this.$u.api.prcutlexecvar({
						iv_code: "PDAPDBACK",
						iv_parm: param,
						ov_var1: '2',
						ov_var2: '2',
						ov_var3: '2',
						ov_var4: '2',
						ov_var5: '2',
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							that.$u.toast(res.msg);
							console.log("返回的res.msg:" + res.msg)
							this.submitPdaBackSuccess()
						} else {
							this.dialogData = {
								title: '货架返回',
								msgType: 'error',
								errContent: res.msg,
								confirmText: '重试',
								// 如果选右边的执行的返回方法
								functionName: 'submitPdaBack',
								cancelText: '关闭',
								closeFunction: '',
							}
							this.errDialogShow()
						}
			
					});
			},
			submitPdaBackSuccess() {
				this.change(0)
				this.huojGoodsList = []
				this.oneMx = {}
				this.mxInfo = {}
				this.searchHz()
				zhendong();
				tishiyin();
			},
			// 提交成功后，刷新汇总集合，如果包含locationid 老的，
			// 那说明这个盘点单还没做完，直接获取明细，
			// 如果不包含，那么提示已经做完，并且跳转到汇总选择页面，供用户选择
			submitSuccess() {

				this.form.uniqcode = ''
				this.removeSelected()
				this.goTo(this.hzData, this.hzIndex)
				zhendong();
				tishiyin();
			},
			removeSelected() {
				this.selectedMx = []
				this.huojGoodsList = this.huojGoodsList.map(v => {
					this.$set(v, 'checked', false)
					return v
				})
			},
			navTo(url) {
				uni.navigateTo({
					url: url
				});
			},
			// 根据货位进行搜索
			getLocationMxList(item) {

				// 1、IV\_STAFF 人员
				// 2、IV_LOCATIONID 货位
				const USER_ID = uni.getStorageSync('USER_ID')
				const locationid = item.LOCATIONID

				let param = USER_ID + "," + locationid;

				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "GETPDHWDETAILDISP",
						iv_parm: param
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							let data = res.data
							console.log("返回的data:" + JSON.stringify(data))
							//补充text
							this.huojGoodsList = data

							this.huojGoodsList = data.map((v, index) => {
								const ID = v.PDNO + '@' + v.SORTSN
								let result = ''
								if (this.selectedMx) {
									result = this.selectedMx.find(it => it === ID);
									if (result) {
										console.log("返回的result:" + JSON.stringify(result))
									}
								}
								console.log("明细的排序:" + index)
								// 如果是开发环境,就放置一个
								if (this.devShow === true) {
									if (index === 0) {
										this.selectedMx.push(ID)
										this.$set(v, 'checked', true)
									}
								} else {
									if (!result) {
										this.selectedMx.push(ID)
									}
									this.$set(v, 'checked', true)
								}

								// this.$set(v, 'AMOUNT', v.SHIP_AMOUNT)

								this.$set(v, 'disabled', false)
								this.$set(v, 'value', ID)
								this.$set(v, 'name', ID)
								return v
							})
							console.log("1111111111111:" + JSON.stringify(this.huojGoodsList))
							// 如果都做完了,就返回到汇总页面
							if (!this.huojGoodsList || this.huojGoodsList === []) {
								this.change(0)
							}
							// this.oneMx = this.huojGoodsList[0]
							this.mxInfo = this.huojGoodsList[0]
							this.oneMx = this.huojGoodsList[0]

							this.status = 'nomore';
						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			// 获取盘点任务列表
			getCheckList() {
				// 1、IV\_STAFF 人员
				// 2、IV\_GZTID 工作台
				// 3、IV\_STORAGEID 仓库
				// 4、IV\_KUF\_NO 库房
				// 5、IV\_QUY\_NO 区域
				const USER_ID = uni.getStorageSync('USER_ID')
				const GZTID = this.GZTID ? this.GZTID : "%"
				const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				const kuf_no = this.form.kuf_no ? this.form.kuf_no : '%'
				const quyu_no = this.form.quyu_no ? this.form.quyu_no : '%'
				let param = USER_ID + "," + GZTID + "," + STORAGE_ID +
					"," + kuf_no + "," + quyu_no;
				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "GETPDHWDISP",
						iv_parm: param
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							let data = res.data
							console.log("返回的data:" + JSON.stringify(data))
							//补充text
							this.hzList = data
							if (this.hzList.length < 1) {
								this.$u.toast("暂无数据");
							}
							this.status = 'nomore';


						} else {
							this.dialogData = {
								title: '盘点汇总查询',
								msgType: 'warn',
								errContent: res.msg,
								confirmText: '重试',
								// 如果选右边的执行的返回方法
								functionName: 'getCheckList',
								cancelText: '关闭',
							}
							this.errDialogShow()
						}
					});
			},
			getOutTpbarList() {
				// 1、IV\_STAFF 用户id
				// 2、IV\_GZTID 工作站
				// 3、IV\_YEW\_TYPE业务类型2：出库
				// const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				// // const USER_GH = uni.getStorageSync('USER_GH')
				// const yez_id = this.form.huoz_id ? this.form.huoz_id : "%"
				const USER_ID = uni.getStorageSync('USER_ID')
				const GZTID = this.GZTID ? this.GZTID : "%"
				const yew_type = '2'
				let param = USER_ID + "," + GZTID + "," + yew_type;
				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "PDAOUTTPBAR",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						// console.log("返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.hzList = data

							this.status = 'nomore';


						} else {
							this.$u.toast(res.msg);
						}
					});
			},

			blurFunction() {
				console.log("失去了焦点")
				this.myMxShow()
			},
			changeProductDate(e) {
				console.log("选择的日期:" + JSON.stringify(e))
				this.oneMx.PRODUCTDATE = e.result
				this.myMxShow()
			},
			changeEFFDATE(e) {
				this.oneMx.EFFDATE = e.result
				this.myMxShow()
			},
			// 下拉内容是否展开
			showSelector(res) {
				// console.log(res)
				// this.showHeight = res
			},
			changeGzt(e) {
				this.GZTID = e
				uni.setStorageSync("IN_GZTID", e)
				console.log("盘点缓存区域号:" + uni.getStorageSync("IN_GZTID"))
				this.showHeight = false
				this.searchHz()
			},
			changeQuyNo(e) {
				this.form.quy_no = e
				uni.setStorageSync("inventory-check-quy_no", e)
				console.log("盘点缓存区域号:" + uni.getStorageSync("inventory-check-quy_no"))
				this.showHeight = false
				this.searchHz()
			},
			changeKuf(e) {
				console.log("e:" + e);
				console.log("this.kufList:" + JSON.stringify(this.kufList))
				// const item = this.kufList[e];
				// console.log("item:"+item)
				this.form.kuf_no = e
				console.log(this.form.kuf_no)
				// 判断一下区域是不是在这个库房,如果在,就不更改区域,如果不在,就更改区域
				this.getKufbyKuf()
				this.notChangeQuyNo = e ? false : true

				uni.setStorageSync("inventory-check-kuf_no", e)
				console.log("盘点缓存库房号:" + uni.getStorageSync("inventory-check-kuf_no"))
				this.showHeight = false
			},
			// 查看选择到的库房的区域
			getKufbyKuf() {
				const USER_ID = uni.getStorageSync('USER_ID')
				const KUB = '%'
				const KUF_NO = this.form.kuf_no ? this.form.kuf_no : "%"
				//1获取库别，2获取库房，3获取区域
				const GET_TYPE = 3
				let param = USER_ID + "," + KUB + "," + KUF_NO + "," + GET_TYPE;
				console.log(param)
				this.$u.api.general({
						iv_code: "GETKUFQUYNO",
						iv_parm: param
					})
					.then(res => {
						console.log("getKufbyKuf返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("查看选择到的库房的区域返回的data:" + JSON.stringify(data))
						if (res.success) {

							this.form.quy_no = uni.getStorageSync("inventory-check-quy_no")
							console.log("this.form.quy_no:" + this.form.quy_no)
							let newData = [];
							if (this.form.quy_no) {
								//补充text
								newData = data.filter((item) => {
									// 过滤如果有对象的区域参数和已经够选择的区域no相同,那么就不用覆盖已经选择的
									return item.QUY_NO === this.form.quy_no
								})
							}

							if (newData.length > 0) {
								console.log("不用重新选择,这是从对象集合种筛出来的区域号相同的对象=>" + JSON.stringify(newData))
								this.quNoList = data.map(v => {
									this.$set(v, 'text', v.QUY_NO)
									this.$set(v, 'value', v.QUY_NO)
									return v
								})
							} else {
								console.log("重新选择,这是库房对应的对象集合,=>" + JSON.stringify(data))
								this.quNoList = data.map(v => {
									this.$set(v, 'text', v.QUY_NO)
									this.$set(v, 'value', v.QUY_NO)
									return v
								})
								//如果切换的区域
								this.form.quy_no = ''
							}
							this.canChangeQuy_no()
						} else {
							this.errContent = res.msg
							this.$u.toast(res.msg);
						}
					});
			},
			// 将区域可选
			canChangeQuy_no() {
				this.notChangeQuyNo = false
			},
			getGzt(loginType) {
				const user_id = uni.getStorageSync('USER_ID')
				const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				const kuf = "%"
				const gztType = "6"
				const gztId = "%"
				let param = user_id + "," + STORAGE_ID + "," + kuf + "," + gztType + "," + gztId;
				console.log(param)
				this.$u.api.general({
						iv_code: "GETGZTINFO",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("getGzt返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.gztList = data.map(v => {
								this.$set(v, 'text', v
									.GZTNAME + "(" + v.GZTID + ")"
								) // https://vuejs.org/v2/guide/reactivity.html
								this.$set(v, 'value', v.GZTID)
								return v
							})
							this.gztList = this.gztList.filter((item) => {
								return item.LETDOWNFLAG === 2
							})

							// 增加一条特殊的测试数据
							// this.gztList.push({
							// 	"text": "DHJ01",
							// 	"WORKLOAD": "4",
							// 	"CENG": "1",
							// 	"GZT_TYPE": "1",
							// 	"ISZCQFP": "N",
							// 	"STORAGEID": "SU3",
							// 	"WORKSTATION_TYPE": "0",
							// 	"LETDOWNFLAG": "1",
							// 	"GZTID": "DHJ01",
							// 	"GZTNAME": "DHJ01测试工作站",
							// 	"KUF_NO": "LHK"
							// })
						} else {
							this.$u.toast(res.msg);
						}
					});
			},

		}

	}
</script>
<style lang="scss" scoped>
	@import '../../common/index.scss';
	@import '../../common/base-change.scss';
</style>